package com.gtallinone.client;

import java.util.ArrayList;

//import com.gtallinone.client.AuthenticationHandler1;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CellPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.HorizontalSplitPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;

public class PhiloPanel extends DockPanel{
	
	VerticalPanel mainPanel, homePanel, ap, adp, fep, fedp;

	public PhiloPanel(){
			
		setSize("100%", "100");
		setBorderWidth(5);
		
		//Main Panel
		mainPanel = new VerticalPanel();
		
		//Home Panel
		homePanel = new VerticalPanel();
		mainPanel.add(homePanel);
		add(mainPanel, DockPanel.CENTER);
		Label jobHome = new Label("Philanthropy at Tech!");
		jobHome.addStyleName("panelTitle");
		HorizontalPanel imagesP = new HorizontalPanel();
		Image image_Job1 = new Image("http://www.gatech.edu/upload/pr/tbj46940.jpg");
		image_Job1.setSize("220px", "200px");
		imagesP.add(image_Job1);
		Image image_Job2 = new Image("http://www.articlesweb.org/blog/wp-content/uploads/2011/10/philanthropy.jpg");
		image_Job2.setSize("220px", "200px");
		imagesP.add(image_Job2);
		Image image_Job3 = new Image("http://womensphilanthropy.typepad.com/.a/6a011571801c18970b014e895ba23e970d-pi");
		image_Job3.setSize("220px", "200px");
		imagesP.add(image_Job3);
		Image image_Job4 = new Image("http://www.buzzle.com/img/articleImages/312644-34930-36.jpg");
		image_Job4.setSize("220px", "200px");
		imagesP.add(image_Job4);
		
		homePanel.add(jobHome);
		homePanel.add(imagesP);

		
		//Announcement Panel
		ap = new VerticalPanel();
		Label apTitle = new Label("Announcements");
		ap.add(apTitle);
		
		apTitle.addStyleName("panelTitle");
		Image imageBar1 = new Image("http://www.cityu.edu.hk/webimage/line/grad.gif");
		imageBar1.setSize("880px", "3px");
		ap.add(imageBar1);
		
		AsyncCallback<ArrayList> callback1 = new AuthenticationHandler1<ArrayList>();
		GTAllInOne.rpc.getPhiloAnnouncement(callback1);
		
		Button skip1 = new Button("Team buzz is looking for coordinators");

		FlexTable flexTable = new FlexTable();
	    flexTable.setWidget(0, 0, new Label("Date"));
	    flexTable.setWidget(0, 1, new Label("Title"));
	    flexTable.setWidget(0, 2, new Label("Author"));
	    flexTable.setWidget(1, 0, new Label("2011-12-01"));
	    flexTable.setWidget(1, 1, skip1);
	    flexTable.setWidget(1, 2, new Label("root"));
	    flexTable.setWidget(2, 0, new Label("2011-12-03"));
	    flexTable.setWidget(2, 1, new Button("Tech Beautificationday is on 2012-04-01"));
	    flexTable.setWidget(2, 2, new Label("root"));
	    flexTable.setStyleName("panel flexTable");
		ap.add(flexTable);
		
		
		skip1.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.remove(0);
				mainPanel.add(adp);
			}
		});
		
		//Announcement Detail Panel
		adp = new VerticalPanel();
		
		Label adpTitleData = new Label("Team buzz is looking for coordinators");
		Label adpAuthorData = new Label("root");
		Label adpDateData = new Label("2011-12-01");
		Label adpDetailData = new Label("Whoever is interested, please contact the office for the first coordinators meeting");
		
		Label adpTitle = new Label("Announcement Detail");
		adp.add(adpTitle);
		adpTitle.addStyleName("panelTitle");
		
		Image imageBar2 = new Image("http://www.cityu.edu.hk/webimage/line/grad.gif");
		imageBar2.setSize("880px", "3px");
		adp.add(imageBar2);
		
		adp.add(new Label("Title: "));
		adp.add(adpTitleData);
		adp.add(new Label("Author: "));
		adp.add(adpAuthorData);
		adp.add(new Label("Date: "));
		adp.add(adpDateData);
		adp.add(new Label("Detail: "));
		adp.add(adpDetailData);
		
		Button adpBack = new Button("Back To Announcements");
		adp.add(adpBack);
		adpBack.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.remove(0);
				mainPanel.add(ap);
			}
		});
		
		//Find Events Panel
		fep = new VerticalPanel();
		Label fepTitle = new Label("Find Events");
		fep.add(fepTitle);
		
		fepTitle.addStyleName("panelTitle");
		Image imageBar3 = new Image("http://www.cityu.edu.hk/webimage/line/grad.gif");
		imageBar3.setSize("880px", "3px");
		fep.add(imageBar3);
		
		Button skip2 = new Button("Books for Africa");
		
		FlexTable flexTable2 = new FlexTable();
		flexTable2.setWidget(0, 0, new Label("Date"));
		flexTable2.setWidget(0, 1, new Label("Starting Time"));
		flexTable2.setWidget(0, 2, new Label("Title"));
		flexTable2.setWidget(0, 3, new Label("Author"));		
		flexTable2.setWidget(1, 0, new Label("2011-12-16"));
	    flexTable2.setWidget(1, 1, new Label("10:00:00"));
	    flexTable2.setWidget(1, 2, skip2);
		flexTable2.setWidget(1, 3, new Label("root"));	
	    flexTable2.setStyleName("panel flexTable");
		fep.add(flexTable2);
		
		skip2.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.remove(0);
				mainPanel.add(fedp);
			}
		});
		
		//Find Event Detail Panel
		fedp = new VerticalPanel();
		
		Label fedpTitle = new Label("Event Detail");
		fedp.add(fedpTitle);
		fedpTitle.addStyleName("panelTitle");
		
		Image imageBar4 = new Image("http://www.cityu.edu.hk/webimage/line/grad.gif");
		imageBar4.setSize("880px", "3px");
		fedp.add(imageBar4);
		
		Label idpTitleData = new Label("Books for Africa");
		Label idpDateData = new Label("2011-12-16");
		Label idpStartTimeData = new Label("10:00:00");
		Label idpEndTimeData = new Label("11:00:00");
		Label idpLocation = new Label("101 Pine Street NW, Atlanta, GA 30313");
		Label idpDetailData = new Label("Organize books to be shipped to Africa!");
		
		fedp.add(new Label("Title: "));
		fedp.add(idpTitleData);
		fedp.add(new Label("Date: "));
		fedp.add(idpDateData);
		fedp.add(new Label("Start Time: "));
		fedp.add(idpStartTimeData);
		fedp.add(new Label("End Time: "));
		fedp.add(idpEndTimeData);
		fedp.add(new Label("Location: "));
		fedp.add(idpLocation);
		fedp.add(new Label("Detail: "));
		fedp.add(idpDetailData);
		
		Button idpBack = new Button("Back To Find Events");
		fedp.add(idpBack);
		idpBack.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.remove(0);
				mainPanel.add(fep);
			}
		});
		
		
		
		//Side Panel and Buttons
		VerticalPanel sidePanel = new VerticalPanel();
		add(sidePanel, EAST);
		Button btnHome = new Button("Home");
		btnHome.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.remove(0);
				mainPanel.add(homePanel);
			}
		});
		Button btnAnnoun = new Button("Announcements");
		btnAnnoun.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.remove(0);
				mainPanel.add(ap);
			}
		});
		Button btnEvents = new Button("Find Events");
		btnEvents.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				mainPanel.remove(0);
				mainPanel.add(fep);
			}
		});

		btnHome.setSize("100%", "100%");
		btnAnnoun.setSize("100%", "100%");
		btnEvents.setSize("100%","100%");
		sidePanel.add(btnHome);
		sidePanel.add(btnAnnoun);
		sidePanel.add(btnEvents);

		
		
	}	
	private class AuthenticationHandler1<T> implements AsyncCallback<ArrayList> {//Handler for Attribute Names for View Listbox3
        public void onFailure(Throwable ex) {
       //RootPanel.get().add(new HTML("RPC call failed. :-("));
           }
		public void onSuccess(ArrayList result) {
        	//RootPanel.get().add(new HTML("RPC call success  : -)"));
			/*
        	attributeNames = result;
        	attribute.clear();
        	for(int i = 0; i < attributeNames.size(); i++){
        		attribute.addItem((String) attributeNames.get(i));
    		}*/
        }

   }
}
